/* eslint-disable array-callback-return,no-undef */
import React, { Component } from 'react';
import { Layout, Tabs, Form, Spin, Avatar } from 'antd';
import styles from '../../index.less';
import Toolbar from '../Common/ToolBar/ToolBarNew';
import * as commonFunc from '../Common/commonFunc';
import CommonBase from '../Common/CommonBase';
import CommonElementEvent from '../Common/CommonElementEvent';
import StaticEditTable from '../Common/CommonTable'; /* 可编辑表格 */
import CommonView from '../Common/CommonView';
import * as commonBusiness from '../Common/commonBusiness'; /* 单据业务功能 */

const { Header, Content } = Layout;
const { TabPane } = Tabs;

class SftLoginInfoComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
    this.form = {}; /*   表单对象   */
  }
  render() {
    const { pageLoading } = this.props;
    return (
      <div>
        <Spin spinning={pageLoading}>
          <div>
            <SftLoginComponent
              {...this.props}
              {...this.state}
            />
          </div>
        </Spin>
      </div>
    );
  }
}
const SftLoginComponent = Form.create({
  mapPropsToFields(props) {
    const { masterData } = props;
    const obj = commonFunc.mapPropsToFields(masterData, Form);
    return obj;
  },
})((props) => {
  const { form, onReturnForm } = props;
  /*   回带表单   */
  onReturnForm(form);
  return (
    <Form>
      <Layout>
        <Header className={styles.header}>
          <Toolbar {...props} />
        </Header>
        <Layout className={styles.clayout}>
          <Content className={styles.content}>
            <CommonView {...props} />
            <div id="slaveTabs" className={styles.bShow}>
              <div>
                <Avatar src={props.imgSrc} />
              </div>
              <Tabs className={styles.slaveTabs}>
                <TabPane tab="权限组" key={2}>
                  <StaticEditTable {...commonBusiness.getTableTypes('jurgroup', props)} />
                </TabPane>
                <TabPane tab="客户查看权限" key={3}>
                  <StaticEditTable {...commonBusiness.getTableTypes('customergroup', props)} />
                </TabPane>
                <TabPane tab="供应商查看权限" key={4}>
                  <StaticEditTable {...commonBusiness.getTableTypes('supplygroup', props)} />
                </TabPane>
                <TabPane tab="人员查看权限" key={5}>
                  <StaticEditTable {...commonBusiness.getTableTypes('persongroup', props)} />
                </TabPane>
                <TabPane tab="工序查看权限" key={6}>
                  <StaticEditTable {...commonBusiness.getTableTypes('processgroup', props)} />
                </TabPane>
              </Tabs>
            </div>
          </Content>
        </Layout>
      </Layout>
    </Form>
  );
});

export default CommonBase(CommonElementEvent(SftLoginInfoComponent));

